<?php

namespace common\models\base;

use Yii;

/**
 * This is the model class for table "{{%edivi_credit_order_users}}".
 *
 * @property int $id
 * @property int $edivi_credit_order_id
 * @property string $type
 * @property string $id_card
 * @property int $sign_mode
 * @property string $issue_authority
 * @property string $phone_num
 * @property string $user_name
 * @property string $start_date
 * @property string $end_date
 * @property string $family_address
 * @property int $is_ca 是否补录
 *
 * @property EdiviCreditOrder $ediviCreditOrder
 * @property EdiviCreditOrderUsersPics[] $ediviCreditOrderUsersPics
 */
class EdiviCreditOrderUsers extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%edivi_credit_order_users}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['edivi_credit_order_id', 'id_card', 'sign_mode', 'issue_authority', 'phone_num', 'user_name', 'start_date', 'end_date', 'family_address'], 'required'],
            [['edivi_credit_order_id', 'sign_mode', 'is_ca'], 'integer'],
            [['type'], 'string'],
            [['id_card', 'issue_authority'], 'string', 'max' => 30],
            [['phone_num'], 'string', 'max' => 11],
            [['user_name'], 'string', 'max' => 50],
            [['start_date', 'end_date'], 'string', 'max' => 10],
            [['family_address'], 'string', 'max' => 200],
            [['edivi_credit_order_id'], 'exist', 'skipOnError' => true, 'targetClass' => EdiviCreditOrder::className(), 'targetAttribute' => ['edivi_credit_order_id' => 'id']],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app', 'ID'),
            'edivi_credit_order_id' => Yii::t('app', 'Edivi Credit Order ID'),
            'type' => Yii::t('app', 'Type'),
            'id_card' => Yii::t('app', 'Id Card'),
            'sign_mode' => Yii::t('app', 'Sign Mode'),
            'issue_authority' => Yii::t('app', 'Issue Authority'),
            'phone_num' => Yii::t('app', 'Phone Num'),
            'user_name' => Yii::t('app', 'User Name'),
            'start_date' => Yii::t('app', 'Start Date'),
            'end_date' => Yii::t('app', 'End Date'),
            'family_address' => Yii::t('app', 'Family Address'),
            'is_ca' => Yii::t('app', '是否补录'),
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getEdiviCreditOrder()
    {
        return $this->hasOne(EdiviCreditOrder::className(), ['id' => 'edivi_credit_order_id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getEdiviCreditOrderUsersPics()
    {
        return $this->hasMany(EdiviCreditOrderUsersPics::className(), ['edivi_credit_order_user_id' => 'id']);
    }
}
